Skip to content

Tests: a streamed reply leaves its keep-alive connection open (#98) - #113

Open
MCsumz wants to merge 2 commits into
cobanov:mainfrom
MCsumz:stream-end-keeps-connection
Open

MCsumz wants to merge 2 commits into
cobanov:mainfrom
MCsumz:stream-end-keeps-connection

Conversation

@MCsumz

@MCsumz MCsumz commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Second from #98. The fix itself now comes with the llama.cpp move (#103, d2bceda3d), which carries ggml-org/llama.cpp#30492 (cf9a9957d): the provider returns true after done(). So patches/0023 is dropped, and this PR keeps only the test that guards it.

Before that fix, the provider called done() and then returned false, and cpp-httplib counted that as a cancelled response: it closed the connection right after one that advertised Keep-Alive. A client that reused it at once got a disconnect; Open WebUI agent chats stopped after their first tool call with "Server Connection Error".

Check Result
tests/server_stream_keepalive_test.py (new, in test-fleet.sh): two streams, then /health, on one connection; chat, messages, responses, completion passed on the old pin with 0023, and failed without it; upstream's own test covers only /completion
Console, main 5e96235 (PS5 Pro, Qwen 3.8 27B UD-Q2_K_XL) an Open WebUI agent chat with 6 tool calls and two follow-ups, no dropped connections

🤖 Generated with Claude Code

…obanov#98)

llama-server's chunk provider called done() and then returned false, and
cpp-httplib counted that as a cancelled response: it closed the connection
right after one that advertised Keep-Alive. A client that reused it at once
got a disconnect; Open WebUI agent chats stopped after their first tool call
with "Server Connection Error". patches/0023 returns true once the body is
complete, as suggested in cobanov#98, so cpp-httplib itself stays unpatched. A
failed final write still fails: cpp-httplib checks it before the provider's
result.

tests/server_stream_keepalive_test.py, run by scripts/test-fleet.sh, sends
two streams and then a plain request over one connection on chat, messages,
responses and completion.

Applied on llama.cpp 970b51c after patches 0001-0018 and patches/fleet; a
second pass of scripts/apply-patches.sh skips it. On macOS the test passes,
and without the change the server closes the connection after the first
stream. With the same end handled in cpp-httplib (memfix8), a 45+ tool-call
Open WebUI agent turn ran on the console without a disconnect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dem3SmAW35vh3Kc6DxfxPm

@cobanov cobanov left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MCsumz, and thanks for fixing it in the provider. You found exactly the right line. llama.cpp made the same fix upstream on Nov 14 (ggml-org/llama.cpp#30492, cf9a9957d), and #103 brought it in this morning. So 0023 no longer applies on main, and merged as it is, this PR would stop the build.

  1. Please drop patches/0023-stream-end-keeps-connection.patch.
  2. Keep tests/server_stream_keepalive_test.py and its line in scripts/test-fleet.sh. Upstream's test covers only /completion, so this is a good guard on four endpoints. Its docstring should point at the upstream fix instead of 0023.
  3. Reword the CHANGELOG entry: the fix comes with the llama.cpp move (ggml-org/llama.cpp#30492), and the test guards it. Please also wrap the long line.

After that it's a quick merge.

The llama.cpp move (cobanov#103, d2bceda3d) carries ggml-org/llama.cpp#30492
(cf9a9957d), which makes the chunk provider return true after done(), so
patches/0023 no longer applies and is dropped. The test stays, on all
four endpoints (upstream's covers only /completion), with its docstring
pointing at the upstream fix; the CHANGELOG entry says the same and is
wrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MCsumz

MCsumz commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Done in 170624c, merged with main:

  1. 0023 dropped.
  2. The test stays on all four endpoints. Its docstring points at Fix connection reuse after streamed responses ggml-org/llama.cpp#30492.
  3. CHANGELOG entry reworded and wrapped.

Console check on main 5e96235 without the patch: PS5 Pro, Qwen 3.8 27B UD-Q2_K_XL, an Open WebUI agent chat with 6 tool calls and two follow-ups. No dropped connections.

BR Marcell

@MCsumz MCsumz changed the title llama-server: a streamed reply leaves its keep-alive connection open (#98) Tests: a streamed reply leaves its keep-alive connection open (#98) Nov 27, 2026
@MCsumz
MCsumz requested a review from cobanov November 27, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants